<template>
	<view class="" style="">
		<customerSearch ref="customerSearch" :maxSearchListLength="maxSearchListLength" :recommendTabValueName="recommendTabValueName"
			:recommendTabShowName="recommendTabShowName" :recommendList="recommendList" @search="handleSearch"
			@cancel="handleCancel" @recommend="handleRecommend" :tagShowName="tagShowName"></customerSearch>
	</view>
</template>

<script>
	import {
		mapMutations
	} from 'vuex';
	import customerSearch from '@/components/customer-search/customer-search.vue'
	export default {
		components: {
			customerSearch
		},
		data() {
			return {
				searchValue: '',
				skuInfoVo: {},
				radius: '100',
				maxSearchListLength: 10, // 历史搜索最大数量
				recommendTabShowName: '大苏打',
				recommendTabValueName: '使得',

				recommendList: [{
						value: 1,
						label: '智能手表'
					},
					{
						value: 2,
						label: '我的嗡嗡'
					},
				],

				page: 1,
				limit: 5,
				pages: 0,
				skuList: [], //请求返回的数据列表
			}
		},
		methods: {
			...mapMutations('search', [
				'setSearchSkuList',
			]),
			/**
			 * 点击取消
			 */
			handleCancel() {},
			/**
			 * 点击更新推荐
			 */
			handleRecommend() {},
			/**
			 * 搜索
			 */
			handleSearch(searchValue, searchItem) {
				this.searchValue = searchValue
				this.searchFlag = true
				//发送请求
				// this.$store.state.home.page = 1
				this.getSkuPageList({
					keyword: searchValue
				})


			},


			async getSkuPageList(form) {

				if (form.keyword !== null && form.keyword !== undefined) {
					// this.flag = false
					this.skuInfoVo = {
						keyword: form.keyword,
					}
				}

				const result = await this.$u.api.getskuList({
					page: this.page,
					limit: this.limit,
					form: this.skuInfoVo
				});

				this.pages = result.pages
				//把result赋值给
				this.skuList = this.skuList.concat(result.records);
				this.$emit("getskuList", this.skuList)
				//放入仓库
				this.setSearchSkuList(this.skuList)

				//改写skulist中的数据,(触底)


			},

		}

	}
</script>

<style>
</style>